use crate::pkg::errno::code::Errno;

pub fn decode_err(err: Errno) -> (i32, String) {
    match err {
        Errno::IsOk => (0, "OK".to_string()),
        Errno::ErrValidation => (20001, "Validation failed.".to_string()),
        Errno::ErrValidationAdd(i) => (20001, format!("{}", i)),
        Errno::ErrDatabase => (20002, "Database error.".to_string()),
        // user
        Errno::ErrUserNotFound => (20102, "The user was not found".to_string()),
        Errno::ErrPassword => (20103, "password Err".to_string()),
        // topic
        Errno::ErrTopicNotFound => (20202, "The Topic was not found".to_string()),
        // device
        Errno::ErrDeviceNotFound => (20301, "The Device was not found".to_string()),
        // core
        Errno::ErrCoreNotFound => (20401, "The Core was not found".to_string()),
        // modules
        Errno::ErrModulesNotFound => (20401, "The Modules was not found".to_string()),
        Errno::ErrToken => (20555, "The token err".to_string()),
    }
}
